{% load staticfiles %}
<footer class="footer">
    2016 © WanFeng Trading Co., Ltd.
</footer>

<script>

        setInterval("startRequest()",60*60*1000);

        function startRequest()
        {
            $.get("{% url 'getnotice' %}", function(result){

                if(result.total > 0){
                    $('#notice-count').html(result.total);
                    $('#notice').html('');
                    var wlist = '';
                    $.each(result["notice"],function(k,w){
                         var link = w.link;
                         if(link == ''){
                             link = '#/ucenter/notice/'+ w.id;
                         }
                         wlist += '<li><a href="'+link+'" target="_blank"><span class="pull-left"><i class="fa fa-bell-o fa-2x text-danger"></i></span>'
                         wlist += '<span>'+w.title+'<br><small class="text-muted">'+w.send_time+'</small></span>'
                         wlist += '</a></li>'
                    });
                    //console.log(wlist);
                    $('#notice').html(wlist);
                    swal({
                        title: "消息提醒!",
                        text: "有"+result.total+"条新消息!",
                        timer: 2000,
                        showConfirmButton: false
                    });
                }
              });

            $.get("{% url 'getMail' %}", function(result){
                if(result.total > 0){
                 $('#mail-count').html(result.total);
                 $('#message').html('');
                    var wlist = '';
                    $.each(result["notice"],function(k,w){

                         wlist += '<li><a href="/ucenter/read-mail/'+ w.id+'" target="_blank"><span class="pull-left"><img src="'+ w.avatar+'" class="img-circle thumb-sm m-r-15" alt="img"></span>'
                         wlist += '<span class="block"><strong>'+ w.sender+'</strong></span><span class="media-body block">'+w.title+'<br><small class="text-muted">'+w.send_time+'</small></span>'
                         wlist += '</a></li>'
                    });
                    //console.log(wlist);
                    $('#message').html(wlist);
                    swal({
                        title: "消息提醒!",
                        text: "有"+result.total+"条新消息!",
                        timer: 2000,
                        showConfirmButton: false
                    });
                }
            });
        }


  </script>

